import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    users: [],
    menus: []
  },
  getters: {
    token(state) {
      return state.users.token
    }
  },
  mutations: {
    setUsers(state, obj) {
      state.users = obj
    },
    setMenus(state, obj) {
      state.menus = obj
    },

  },
  actions: {
    out({ commit }) {
      commit('setUsers',[])
      commit('setMenus',[])
    }
  },
  modules: {
  },
  plugins: [persistedState()]
})
